package com.heima.wemedia.controller.v1;

import com.heima.model.article.dtos.ApArticleLikeDto;
import com.heima.model.article.dtos.ApArticleListDto;
import com.heima.model.article.dtos.ApArticleOpenCommentDto;
import com.heima.model.comment.dtos.CommentRepaySaveDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ManagerCommentPageDto;
import com.heima.wemedia.service.WmCommentManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/comment/manage")
public class ManageCommentController {
    @Autowired
    private WmCommentManageService wmCommentManageService;

    /**
     * 作者查询评论列表
     */
//    @PostMapping("/find_news_comments")
    public ResponseResult toFindComment(@RequestBody ManagerCommentPageDto pageDto){
        return wmCommentManageService.findNewsComments(pageDto);
    }

    /**
     * 开启或关闭评论
     * @param openDto
     * @return
     */
//    @PostMapping("/update_comment_status")
    public ResponseResult toOpenComment(@RequestBody ApArticleOpenCommentDto openDto){
        return wmCommentManageService.toOpenComment(openDto);
    }

    /**
     * 查看文章的详细评论信息
     * @param listDto
     * @return
     */
//    @PostMapping("/list")
    public ResponseResult toList(@RequestBody ApArticleListDto listDto){
        return wmCommentManageService.toListComment(listDto);
    }

    /**
     * 回复评论
     * @param dto
     * @return
     */
//    @PostMapping("/comment_repay")
    public ResponseResult saveCommentRepay(@RequestBody CommentRepaySaveDto dto){
        return wmCommentManageService.saveCommentRepay(dto);
    }

    /**
     * 评论点赞
     * @param dto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult toLikeComment(@RequestBody ApArticleLikeDto dto){
        return wmCommentManageService.toLikeComment(dto);
    }

    /**
     * 评论删除
     * @param commentId
     * @return
     */
    @DeleteMapping("/del_comment/{commentId}")
    public ResponseResult delComment(@PathVariable("commentId") Long commentId){
        return wmCommentManageService.delComment(commentId);
    }


    /**
     * 删除评论回复
     * @param commentRepayId
     * @return
     */
    @DeleteMapping("/del_comment_repay/{commentRepayId}")
    public ResponseResult delCommentRepay(@PathVariable("commentRepayId") Long commentRepayId){
        return wmCommentManageService.delCommentRepay(commentRepayId);
    }
}
